#include <ctime>
#include <iostream>
#include"../../CuLibDGGSKernel/ISEA4H/ISEA4HImpl.cuh"
using namespace NNU::DGGS;
using namespace NNU::DGGS::Kernel;
using namespace NNU::DGGS::Base;
using namespace NNU::DGGS::Kernel::ISEA4H;

/// <summary>
/// raster2Grid
/// </summary>
/// <param name="srcFilePath">源文件夹</param>
/// <param name="tagFilePath">目标文件</param>
/// <param name="exFormat">拓展名</param>
/// <param name="pGridDimX">GPU网X维度</param>
/// <param name="pBlockDimX">GPU块X维度</param>
/// <param name="pGridType">格网类型</param>
/// <param name="pElementType">要素类型</param>
/// <param name="level">层级</param>
void raster2Grid(const char* srcFilePath, const char* tagFilePath, const char*exFormat, int pGridDimX, int pBlockDimX, DGGSGridType pGridType, DGGSElementType pElementType, int level, int originLevel=10);


/// <summary>
/// grid2Raster
/// </summary>
/// <param name="srcFilePath">源文件夹</param>
/// <param name="tagFilePath">目标文件</param>
/// <param name="exFormat">拓展名</param>
/// <param name="pGridDimX">GPU网X维度</param>
/// <param name="pBlockDimX">GPU块X维度</param>
/// <param name="flag">源数据类型标志</param>
void grid2Raster(const char* srcFilePath, const char* tagFilePath,const char*exFormat,int pGridDimX,int pBlockDimX,int flag);


int main(int argc, char *argv[])
{
    std::string optionString=argv[1];
    std::string srcFilePath=argv[2];
    std::string tagFilePath=argv[3];
    std::string exFormat=argv[4];
    int gridDimX=std::stoi(argv[5]);
    int blockDimX=std::stoi(argv[6]);
    DGGSGridType gridType= getGridTypeFromStr(argv[7]);
    DGGSElementType elementType=getElementTypeFromStr(argv[8]);

    std::clock_t start = std::clock();
    if(optionString=="Raster2Grid")
    {
        int level=std::stoi(argv[9]);
        int originLevel=10;
        if(argc>=11)
            originLevel=std::stoi(argv[10]);
        raster2Grid(srcFilePath.c_str(), tagFilePath.c_str(),exFormat.c_str(), gridDimX, blockDimX,gridType,elementType, level, originLevel);
    }
    else if(optionString=="Grid2Raster")
    {
        int flag=std::stoi(argv[argc-1]);
        grid2Raster(srcFilePath.c_str(), tagFilePath.c_str(),exFormat.c_str(), gridDimX, blockDimX,flag);
    }
    else
        std::cerr<<"parameters are wrong"<<std::endl;
    std::clock_t end = std::clock();
    std::cout<<"time:"<<(double)(end - start) / CLOCKS_PER_SEC<<" seconds"<<std::endl;return 0;
}